#pragma once

#include "CallBehaviorAction.h"

#include "Behavior.h"
#include "Parameter.h"

namespace uml {

CallBehaviorAction::CallBehaviorAction(const QString& umlType)
    : CallAction(umlType) {}

void CallBehaviorAction::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    CallAction::fromJson(json, errorList);
    behavior_ = JsonSerializable::create<Behavior>(json.value("behavior"), errorList);

}

void CallBehaviorAction::toJson(QJsonObject& json) {
    CallAction::toJson(json);
    if (behavior_) {
        QJsonObject behavior_json;
        behavior_->toJson(behavior_json);
        json.insert("behavior", behavior_json);
    }
}

/// <summary>
/// outputParameters
    /// Return the inout, out and return ownedParameters of the Behavior being called.
/// </summary>
    /// <code>
    /// result = (behavior.outputParameters())
    /// </code>
shared_ptr<vector<Parameter>> CallBehaviorAction::outputParameters() const
{
    return nullptr;
}

/// <summary>
/// inputParameters
    /// Return the in and inout ownedParameters of the Behavior being called.
/// </summary>
    /// <code>
    /// result = (behavior.inputParameters())
    /// </code>
shared_ptr<vector<Parameter>> CallBehaviorAction::inputParameters() const
{
    return nullptr;
}

/// <summary>
/// behavior getter
/// The Behavior being invoked.
/// </summary>
shared_ptr<Behavior> CallBehaviorAction::behavior() const {
    return behavior_;
}

/// <summary>
/// behavior setter
/// The Behavior being invoked.
/// </summary>
void CallBehaviorAction::setBehavior(shared_ptr<Behavior> value) {
    behavior_ = value;
}

} // namespace uml
